package com.swjd.controller;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.swjd.pojo.Home;
import com.swjd.pojo.User;
import com.swjd.service.IHomeService;


@Controller
public class HomeController {

	@Autowired
	private IHomeService homeService;
	
	@RequestMapping("getAll.do")
	public String getAll(Model model){
		List<Home> list=homeService.allHome();
		model.addAttribute("list",list);
		return "NewFile.jsp";
	}
	
	
	@RequestMapping("sell.do")
	public ModelAndView sel(Model model,@Param("rname")String rname) {
		ModelAndView mv = new ModelAndView();
        List<Home> list = homeService.sell(rname);
		if (rname != null) {
            mv.addObject("list", list);
            mv.setViewName("Home.jsp");
        }return mv;
	}
	
	@RequestMapping("selcon.do")
	public ModelAndView selcon(Model model,@Param("pricestart")String pricestart,@Param("priceend")String priceend) {
		ModelAndView mv = new ModelAndView();
        List<Home> list = homeService.selcon(pricestart, priceend);
        Integer.parseInt(pricestart);
        Integer.parseInt(priceend);
        if (pricestart !=null && !pricestart.equals("")) {
            mv.addObject("list", list);
            mv.setViewName("Home.jsp");
        }return mv;
	}

	
}
